{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from sklearn.metrics import r2_score\n",
    "\n",
    "class LogisticRegression:\n",
    "    \n",
    "    def __init__(self):\n",
    "        \"\"\"初始化Linear Regression模型\"\"\"\n",
    "        self.coef_ = None\n",
    "        self.interception_ = None\n",
    "        self._theta = None\n",
    "    \n",
    "    def _sigmoid(self, t):\n",
    "            return 1. / (1. + np.exp(-t))\n",
    "        \n",
    "    def fit(self, X_train, y_train, eta=0.01, n_iters = 1e4):\n",
    "        \"\"\"根据训练数据集X_train, y_train，使用梯度下降法训练Linear Regression模型\"\"\"\n",
    "        assert X_train.shape[0] == y_train.shape[0], \"the size of X_train must be equal to the size of y_train\"\n",
    "        \n",
    "\n",
    "        \n",
    "        def J(theta, X_b, y):\n",
    "            y_hat = self._sigmoid(X_b.dot(theta))\n",
    "            try:\n",
    "                return np.sum(y*np.log(y_hat) + (1-y)*np.log(1-y_hat))\n",
    "            except:\n",
    "                return float('inf')\n",
    "            \n",
    "        def dJ(theta, X_b, y):\n",
    "            return X_b.T.dot(self._sigmoid(X_b.dot(theta))-y) / len(X_b)\n",
    "        \n",
    "        def gradient_descent(X_b, y, initial_theta, eta, n_iters = 1e4, epsilon=1e-8):\n",
    "            theta = initial_theta\n",
    "            i_iter = 0\n",
    "            while i_iter < n_iters:\n",
    "                gradient = dJ(theta, X_b, y)\n",
    "                last_theta = theta\n",
    "                theta = theta - eta * gradient\n",
    "                if (abs(J(theta, X_b, y) - J(last_theta, X_b, y)) < epsilon):\n",
    "                    break\n",
    "                i_iter += 1\n",
    "            return theta\n",
    "        \n",
    "        X_b = np.hstack([np.ones((len(X_train), 1)), X_train])\n",
    "        initial_theta = np.zeros(X_b.shape[1])\n",
    "        self._theta = gradient_descent(X_b, y_train, initial_theta, eta)\n",
    "        self.interception_ = self._theta[0]\n",
    "        self.coef_ = self._theta[1:]\n",
    "        return self\n",
    "        \n",
    "    def predict_proba(self, X_predict):\n",
    "        \"\"\"给定待预测数据集X_predict，返回表示X_predict的结果向量\"\"\"\n",
    "        assert self.interception_ is not None and self.coef_ is not None, \"must fit before predict\"\n",
    "        assert X_predict.shape[1] == len(self.coef_), \"the feature number of X_predict must equal to X_train\"\n",
    "        \n",
    "        X_b = np.hstack([np.ones((len(X_predict), 1)), X_predict])\n",
    "        return self._sigmoid(X_b.dot(self._theta))\n",
    "    \n",
    "    def predict(self, X_predict):\n",
    "        \"\"\"给定待预测数据集X_predict，返回表示X_predict的结果向量\"\"\"\n",
    "        assert self.interception_ is not None and self.coef_ is not None, \"must fit before predict\"\n",
    "        assert X_predict.shape[1] == len(self.coef_), \"the feature number of X_predict must equal to X_train\"\n",
    "        \n",
    "        proba = self.predict_proba(X_predict)\n",
    "        return np.array(proba>=0.5, dtype=int)\n",
    "    \n",
    "    def score(self, X_test, y_test):\n",
    "        \"\"\"根据测试数据集X_test, y_test确定当前模型的准确度\"\"\"\n",
    "        \n",
    "        y_predict = self.predict(X_test)\n",
    "        return r2_score(y_test, y_predict)\n",
    "        \n",
    "    def __repr__(self):\n",
    "        return \"LogisticRegression()\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 实现逻辑回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn import datasets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "iris = datasets.load_iris()\n",
    "X = iris.data\n",
    "y = iris.target\n",
    "X = X[y<2, :2]  # 逻辑回归只能解决二分类问题，因此只选取其中两种花的数据\n",
    "y = y[y<2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(100, 2)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(100,)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD5CAYAAAA3Os7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAXn0lEQVR4nO3dfYxcV3nH8d/j2RQwASI1qxLFL6sKhNREzotXISgVCjiteLGMKkBytZQaFbm1SQlqK9oQKRKWUFVValNI7WgJqkLjltDwUoNSWhKIGlRhtA4hEEwrg+LEhDabpCSlBirbT/+4s/Ls7MzsPTNz5p5z5vuRrnbmzsnd59x798n1uc89Y+4uAED+NjQdAABgPEjoAFAIEjoAFIKEDgCFIKEDQCFI6ABQiJm6Dc2sJWlJ0g/dfWfXZ3sk/bmkH7ZX3e7udw7a3sUXX+xzc3NBwQLAtDt27Ngz7j7b67PaCV3STZKOS3p5n8/vcfcb625sbm5OS0tLAb8eAGBmJ/t9VmvIxcw2SXqrpIFX3QCA5tQdQ79N0gclnRvQ5u1m9qiZ3Wtmm3s1MLO9ZrZkZkvLy8uhsQIABlg3oZvZTklPu/uxAc2+IGnO3bdJul/SXb0aufuiu8+7+/zsbM8hIADAkOpcoV8naZeZPS7pU5LeaGZ3dzZw92fd/efttx+XtH2sUQIA1rVuQnf3m919k7vPSdot6Svu/q7ONmZ2ScfbXapungIAJiikymUVMzsgacndj0h6v5ntknRG0nOS9ownPABAXUEPFrn7gys16O5+azuZr1zFX+buV7j7G9z9ezGCBRpx+LA0Nydt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krq+ETb7Y7de/6RMj5+7/7ukK6XqolHSDyV9rqtZlOM3tVfoZrZJ0lsl3dl0LA16m6RPeuXrki4ys0uaDmramdnLJb1e1Xf5yt3/z91/3NUs22NXs3+l2CHp++7e/VR8lOM3tQld0m2SPijp3IA2b2//c+heM9s8objGySX9i5kdM7O9PT6/VNKTHe9PtdflYL2+SdLrzOxbZvZPZnbZJIMb0S9LWpb0N+0hwTvN7KVdbXI+dnX6J+V7/DrtlvT3PdZHOX5TmdDNbKekp9392IBmX5A05+7bJN0v6a6JBDde17n71ar+efc+M3t91+e9vis2lzrW9fr2sKo5L66Q9DFJn590gCOYkXS1pEPufpWk/5X0J11tcj52dfqX8/GTJLWHknZJ+odeH/dYN/Lxm8qELuk6SbvM7HFJn5L0RjO7u7OBuz/r7j9vv/24pO2TDXF07v5U++fTqsbwrulqckpS5788Nkl6ajLRjWa9vrn7C+7+k/br+yRdYGYXTzzQ4ZySdMrdj7bf36sqAXa3yfLYqUb/Mj9+K94s6WF3/68en0U5flOZ0N39Znff5O5zqv5J9BV3f1dnm67xrF2qbp5mw8xeamYvW3kt6dclfaer2RFJ727fcb9W0vPu/qMJhxqsTt/M7JVmZu3X16g615+ddKzDcPf/lPSkmb2mvWqHpO92Ncvy2En1+pfz8evwm+o93CJFOn7TXuWyipkdkLTk7kckvd/Mdkk6I+k5SXuajG0IvyTpc+2/iRlJf+fuXzKz35Mkd79D0n2S3iLphKTTkt7TUKyh6vTtHZL2mdkZST+VtNvzeiz69yUdbv+z/QeS3lPIsVuxXv+yPn5mtlHSr0n63Y510Y8fj/4DQCGmcsgFAEpEQgeAQpDQAaAQJHQAKAQJHQAKQUIHgEKQ0AGgEP8P3x3UprO23Z8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X[y==0,0],X[y==0,1], color='red')\n",
    "plt.scatter(X[y==1,0],X[y==1,1], color='blue')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 使用逻辑回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=666)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "LogisticRegression()"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log_reg = LogisticRegression()\n",
    "log_reg.fit(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log_reg.score(X_test, y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.93292947, 0.98717455, 0.15541379, 0.01786837, 0.03909442,\n",
       "       0.01972689, 0.05214631, 0.99683149, 0.98092348, 0.75469962,\n",
       "       0.0473811 , 0.00362352, 0.27122595, 0.03909442, 0.84902103,\n",
       "       0.80627393, 0.83574223, 0.33477608, 0.06921637, 0.21582553,\n",
       "       0.0240109 , 0.1836441 , 0.98092348, 0.98947619, 0.08342411])"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log_reg.predict_proba(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0,\n",
       "       1, 1, 0])"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0,\n",
       "       1, 1, 0])"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log_reg.predict(X_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 决策边界"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 3.01749692, -5.03046934])"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log_reg.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.6827383698993108"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log_reg.interception_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "def x2(x1):\n",
    "    return (-log_reg.coef_[0] * x1 - log_reg.interception_) / log_reg.coef_[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3deXhU9dXA8e8hrJFVQVRCwg4iVTaRRREFr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KmJaQ2OkJcCT9mItKA4Bl4c+AM4CQR+XnZxcpZ9YSPl2cTOtALuEpENgD/BC4WkfFllskHmgKE/qSpB+xxOy5V3a2qR0Mv/w50cTimY/vdGvq5g+AYYrcyi3xzvEIy+P6fgAmPS1X3q+rB0PMpQDURaehwWPlAvqp+Hnr9LsFEWnaZRB+viHG5dLyOdznwhap+Xc48Vz5jIRXG5dIx6wesV9WdqloM/BvoWWaZuOYwzyZ0VX1AVTNUtRnBP6M+VtWyv93eB24KPb8utIyjZwPRxFVmzPAqghdPHSUiJ4lInWPPgUuB5WUWex/4RagSoTvBPwG3uR2XiJx2bNxQRLoR/FzudjIuVd0ObBaRtqFJfYGcMosl/HhFE5cbx6uMG6h4WCPhxyyauFw6ZpuA7iKSHtp3X76fC+Kaw/xQ5fIdIjISWKSq7xO8cPQPEckj+FttoEfiulNErgJKQnENTkAIjYH/hD6zVYG3VHWaiNwOoKpjgSlAfyAPOAzc7JG4rgOGikgJUAgMdPoXc8hvgAmhP9XXATd74HhFE5dbxwsRSQcuAX513DTXj1kUcSX8mKnq5yLyLsHhnhLgS2CckznMvvpvjDFJwrNDLsYYYyrHEroxxiQJS+jGGJMkLKEbY0ySsIRujDFJwhK6McYkCUvoxhiTJP4fg9ca8RZ9qsMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x1_plot = np.linspace(4, 8, 1000)\n",
    "x2_plot = x2(x1_plot)\n",
    "\n",
    "plt.plot(x1_plot, x2_plot)\n",
    "plt.scatter(X[y==0,0],X[y==0,1], color='red')\n",
    "plt.scatter(X[y==1,0],X[y==1,1], color='blue')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_decision_boundary(model, axis):\n",
    "    x0, x1 = np.meshgrid(\n",
    "        np.linspace(axis[0], axis[1], int((axis[1]-axis[0])*100)).reshape(-1,1),\n",
    "        np.linspace(axis[2], axis[3], int((axis[3]-axis[2])*100)).reshape(-1,1)\n",
    "    )\n",
    "    X_new = np.c_[x0.ravel(), x1.ravel()]\n",
    "    \n",
    "    y_predict = model.predict(X_new)\n",
    "    zz = y_predict.reshape(x0.shape)\n",
    "    \n",
    "    from matplotlib.colors import ListedColormap\n",
    "    custom_cmap = ListedColormap(['#EF9A9A','#FFF59D','#90CAF9'])\n",
    "    \n",
    "    plt.contourf(x0, x1, zz, cmap=custom_cmap)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAcTElEQVR4nO3df6zddX3H8ef7Xi63ooWKKBBaV5eyscxMKg0d6TAM3IJAShox1FwnGE2nnVOGixsjwYQ/SMgSoptDU2FbwY4xqt0qKpmLgpVhk1uGoJQt3Yajyg+hFOi6lrb3vT/OOe29355zz+ec8/l+v5/v9/t6JA33fs/3fs/7fGnf/fZzXt/3MXdHRETqb6zsAkREpBhq+CIiDaGGLyLSEGr4IiINoYYvItIQavgiIg0R3PDNbNzM/s3M7u/y2LVm9gsze6z962NxyxQRkVGdMMC+nwZ2Aif3ePxed//k6CWJiEgegq7wzWwxcDlwR77liIhIXkKv8D8PfBZYOM8+7zez9wD/AfyRuz+T3cHM1gHrAN44OXne2WecMWC5IiLN9thPf/qiu791mJ/t2/DN7ArgBXffYWYX9djtG8A97n7QzD4ObAQuzu7k7huADQDLly7179144zA1i4g01pvXrfvpsD8bsqSzClhtZk8Dfw9cbGZfnb2Du7/k7gfb334FOG/YgkREJB99G7673+D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nl6PlvW0xrCF7p+tWe+FiP3cBud9/e/n4zrQaa3SfJc09A/Ymf/473AY+6+/NdHkv5/Hf0rH+Y859rw3f3G9x9sbsvpfXPku+6+4cyu20Frml/fVV7nyT+lg2pP7Pmt5rWm7tJMLM3mtnCztfA7wLZCaVbgQ+3Ewu/Cbzi7s8WXOpxQmq3hMd6uPtzwDNm1plseAnwZGa3JM89hNWf8vmf5YP0Xg5J9vzP0rP+Yc5/USmdOczsZmDa3bfSelPobjPbRevKfm0ZNQ0iU/+nzGw1cJhW/deWWVvG6cCW9u+JE4C/c/cHzOzjcHQ0xreAy4BdwH7gIyXVmhVS+7BjPYryh8Cm9j/L/wv4SEXOfUe/+pM+/2Z2EvA7wO/P2laZ8x9Q/8DnX6MVREQaQnfaiog0hBq+iEhDqOGLiDSEGr6ISEOo4YuINIQavohIQ6jhi4g0xP8DNcv3i1NsTw8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_decision_boundary(log_reg, axis=[4,7.5,1.5,4.5])\n",
    "plt.scatter(X[y==0,0],X[y==0,1], color='red')\n",
    "plt.scatter(X[y==1,0],X[y==1,1], color='blue')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### KNN的决策边界"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "KNN方法的决策边界没有表达式，但仍可以绘制出决策边界"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',\n",
       "                     metric_params=None, n_jobs=None, n_neighbors=5, p=2,\n",
       "                     weights='uniform')"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "\n",
    "knn_clf = KNeighborsClassifier()\n",
    "knn_clf.fit(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "knn_clf.score(X_test, y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAclElEQVR4nO3df4xd5X3n8fd3hmEcEsPEkADCbp3KaSM1KhAsXOR1xIbsigAyskIE1YRClMhtSZpQGqWlkYjEH0jWSii0WRI50NYQL0shceuQBG2qBOKwxJKhJBRMI7dNaif8CDbmx7o2tue7f9xzxzNn7sx97p3nnvOc+3xe0oiZc4/P/d6D/fXj53zOc8zdERGR4TdSdwEiIlINNXwRkUyo4YuIZEINX0QkE2r4IiKZUMMXEclEcMM3s1Ez+ycze6jDa9eb2a/M7Kni6xNxyxQRkcU6qYd9PwPsBk6d5/X73f1Tiy9JREQGIWiEb2bLgcuBuwZbjoiIDEroCP+LwOeApQvs82Ezez/wU+BP3H1veQcz2whsBHjr+PgF7z7rrB7LFRFp2f+W0+suoRZ7n3vyZXd/Rz+/tmvDN7MrgJfc/Qkzu3ie3b4J3OfuR8zsD4EtwAfKO7n7ZmAzwPkrV/r3P//5fmoWkUxNTI5yxzMfrbuMWt144fjP+/21ISP8tcB6M7sMWAKcamZfc/fps+7u+2fs/1VgU78FiYiUTTf6Z+qupNm6Nnx3vxm4GaAY4X92ZrMvtp/t7s8XP66ndXFXRGTR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bZB6wAMLOTgNNIZ3XOrvW7+353P1L8+FXggmpLXJi7/7L470u05gAvLO0yff4Ly2ktgle7brUnvqzHPmCfu+8sfn6QVgMt75PkuSeg/sTPf9uHgCfd/cUOr6V8/tvmrb+f8z/Qhu/uN7v7cndfSeufJd9z94+WdtsOXFd8f1WxTxJ/y4bUX5rzW0/r4m4SzOytZra0/T3w34HyCqXbgd8vEgu/C7zq7s9XXOocIbVbwst6uPsLwF4za69seAnwbGm3JM89hNWf8vmf4feYfzok2fM/w7z193P+q0rpzGJmtwK73H07rYtC95rZHloj+2vqqKkXpfo/bWbrgWO06r++ztpKzgS2Fb8nTgL+l7s/bGZ/CNNLY3wbuAzYAxwCPlZTrWUhtfe7rEdV/hjYWvyz/N+AjzXk3Ld1qz/p829mpwD/DfiDGdsac/4D6u/5/GtpBRGRTOhOWxGRTKjhi4hkQg1fRCQTavgiIplQwxcRyYQavohIJtTwRUQy8f8BplB9+g/A1cUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_decision_boundary(knn_clf, axis=[4,7.5,1.5,4.5])\n",
    "plt.scatter(X[y==0,0],X[y==0,1], color='red')\n",
    "plt.scatter(X[y==1,0],X[y==1,1], color='blue')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',\n",
       "                     metric_params=None, n_jobs=None, n_neighbors=5, p=2,\n",
       "                     weights='uniform')"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "knn_clf_all = KNeighborsClassifier()\n",
    "knn_clf_all.fit(iris.data[:,:2], iris.target)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
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PrpQA+Aqh4F3gGmhhCXk1ucAH9e+FP0CRFpCSkuJwV+LCIvSL5VhdPQ9SzYW1gWNrc4odCSQ0R+JCJnhhkccBrwJvDPhWm8b4vIiY5t4nAtvcQJ0V5LpyuBR0ssj8P1HK5cnBDx9VTV14G/A/YAvwfeUdUfOzarOHfWNOGLyGeBfar6wliblVgWaq2oxzi/D8xS1bOBn3LsN2vYFqnqx8j/eXyDiJzvWB/59Sxwi/NFYKaq/jHwLeDfQo7vOOBjwP2qei7wLvA1xzZxuJZe4oz6Wg4pTDldBjxeanWJZZHUhbvEGfn1FJEp5EfwHwY+BJwoIkudm5X46JjXs9Yj/EXAZSLyGvBd4EIRcfY+3Qu0ABT+dDmJ8Ltzusapqm+r6pHCjw8CHw83xKE4flf4333k5x7Pc2wydD0Lmhn9p2DNucUZg5Yce4G9qtpV+PkJ8onVuU3U19I1zhhcy+E+A7yoqm+UWBeH61lUNs6YXM9PAb9V1TdVdQD4HvAJxzYV586aJnxVvVVVm1V1Fvk/n36uqs7fUk8CVxe+v7ywTai/9b3E6ZhrvIz8zd1QiciJItJQ/B74U8DZcfRJYHmhImIB+T8Ffx+3OCXilhyq+gegR0SKnQcvAl5xbBb5tfQSZ9TX0uEqyk+TRH49hykbZ0yu5x5ggYhMLMRyEaNzTsW5M6wqnRFE5C6gW1WfJH8z6mER2Un+t9OVUcRUiiPOr4jIZcBR8nFeE0FIJwObCv8WjwP+p6o+JSLXwVCri83AJcBOoA/4QkzjrLYlR5BuBDoLf97vAr4Qw2vpJc44XEtEZCLwX4G/GLYsdtfTQ5yRX09V7RKRJ8hPLx0FfgV0+M2d1lrBGGNSwp60NcaYlLCEb4wxKWEJ3xhjUsISvjHGpIQlfGOMSQlL+MYYkxKW8I0xJiX+P6tVJ30F9NNwAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_decision_boundary(knn_clf_all, axis=[4,8,1.5,4.5])\n",
    "plt.scatter(iris.data[iris.target==0,0],iris.data[iris.target==0,1], color='red')\n",
    "plt.scatter(iris.data[iris.target==1,0],iris.data[iris.target==1,1], color='blue')\n",
    "plt.scatter(iris.data[iris.target==2,0],iris.data[iris.target==2,1], color='green')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "黄色与蓝色之间的边界存在过拟合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',\n",
       "                     metric_params=None, n_jobs=None, n_neighbors=50, p=2,\n",
       "                     weights='uniform')"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "knn_clf_all = KNeighborsClassifier(n_neighbors=50)\n",
    "knn_clf_all.fit(iris.data[:,:2], iris.target)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3df5AU9d3g8fdnxoUVWYTFnBp2gfhISUB9YtxHRA5NNJcYtUxx0azWBmNC3EOMQX3untKQ8gcVU/fU85RiEtFbQ54T5AxqwnMmIT7JU4mGeLp1qzHhUcjJQ4SFGFEBWVwXlpnP/TEzy+7szHbPdE//mP68qrac+XZP92da/ex3uz/9aVFVjDHG1L9U2AEYY4wJhiV8Y4xJCEv4xhiTEJbwjTEmISzhG2NMQljCN8aYhHCd8EUkLSK/E5Gfllh2vYi8LSKv5H++6m+Y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z6WQ/KnnK4Eniy1uMRYKHXhDnGGfjxFZAq5GfxHgA8DJ4jIF4tXK/HRMY9nrWf4C4ArReQN4IfAxSJS/ITk3UArQP5PlxMJvjunY5yq+q6qHs6/fQQ4N9gQh+L4c/6fe8mdezyvaJWh45nXwug/BWvOKc4ItOTYDexW1e78+6fIJdbidcI+lo5xRuBYDvdZ4GVVfavEsigcz4KycUbkeH4K+JOqvq2qg8CPgQuK1qk4d9Y04avqHaraoqozyf359CtVLf4t9TTwpfzrq/LrBPpb302cRecaryR3cTdQInKCiDQVXgOfZnTH0aeB6/IVEeeT+1PwzajFKSG35FDVvwC9InJGfugS4LWi1UI/lm7iDPtYFrmW8qdJQj+ew5SNMyLHcxdwvohMyMdyCaNzTsW5M6gqnRFEZCXQo6pPk7sYtU5EtpP77XRNGDGVUhTn10XkSuAouTivDyGkk4GN+f8WjwP+l6o+IyJLYajVxSbgMmA70A98OaJxVtuSw083A+vzf97vAL4cwWPpJs4oHEtEZALwn4D/MmwscsfTRZyhH09V7RaRp8idXjoK/A7o8po7rbWCMcYkhN1pa4wxCWEJ3xhjEsISvjHGJIQlfGOMSQhL+MYYkxCW8I0xJiEs4RtjTEL8f88t8XziHvR9AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_decision_boundary(knn_clf_all, axis=[4,8,1.5,4.5])\n",
    "plt.scatter(iris.data[iris.target==0,0],iris.data[iris.target==0,1], color='red')\n",
    "plt.scatter(iris.data[iris.target==1,0],iris.data[iris.target==1,1], color='blue')\n",
    "plt.scatter(iris.data[iris.target==2,0],iris.data[iris.target==2,1], color='green')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "k值越大，模型越简单"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
